public class Work03 {
    //猜数字
    public int guessNumber(int n) {
        int left = 1;
        int right = n;
        int mid = 0;
        int guess;
        while(left <= right){
            mid = left + (right -left) / 2;
            guess = guess(mid);
            if(guess == 0){
                return mid;
            }else if(guess == -1){
                right = mid-1;
            }else{
                left = mid +1;
            }
        }
        return mid;
    }
}
